import { createStore } from 'vuex'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    cartlist:[],
  },
  mutations: {
    addCart(state,val){
      let i = state.cartlist.findIndex(item => item.id == val.id);
      if (i>-1){
        state.cartlist[i].num++
      } else {
        state.cartlist.push(val);
      }
      
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    new persist({
      storage: window.localStorage,
    }),
  ],
})
